package org.hot100_2;

import org.leetcode.TreeNode;

import java.util.ArrayList;
import java.util.List;

public class leetcode230 {

    List<Integer> list = new ArrayList<>();
    public int kthSmallest(TreeNode root, int k) {
        tree2List(root);
        return list.get(k-1);
    }

    private void tree2List(TreeNode root){
        if (root==null){
            return ;
        }
        tree2List(root.left);
        list.add(root.val);
        tree2List(root.right);
    }
}
